<?php
class Table_Language extends CF_Db_Table_Abstract
{
	protected $_name = '##_languages';
	
	public function getList()
	{
		return $this->select('*', null, new CF_Db_Expr('`index` ASC'))
				->getAll();
	}
	
	public function insert($data)
	{
		$data['index'] = new CF_Db_Expr('(SELECT IFNULL((SELECT MAX(`index`) FROM ##_languages l), -1) + 1)');
		return parent::insert($data);
	}
}